<!--  -->
<template>
  <el-container>
    <el-header height="80px">
      <div class="title">云音乐歌手榜</div>
      <span
        @click="itemClick(index, index + 1)"
        class="adress"
        :class="{ active: currentIndex === index }"
        v-for="(item, index) in adress"
        :key="index"
        >{{ item }}</span
      >
    </el-header>

    <el-main>
      <div class="top">
        <el-row :gutter="0">
          <el-col
            :span="6"
            v-for="(item, index) in list.slice(0, 3)"
            :key="index"
            style="padding-right: 0"
          >
            <div @click="toDetail(item.id)">
              <div class="left">
                <div>{{ item.name }}</div>
                <span>热度:{{ item.score }}</span>
              </div>
              <div class="rank">{{ index + 1 }}</div>
              <div class="img">
                <img :src="item.picUrl" alt="" />
              </div>
            </div>
          </el-col>
        </el-row>
      </div>

      <div class="all">
        <ul>
          <li
            v-for="(item, index) in list.slice(3)"
            :key="index"
            @click="toDetail(item.id)"
          >
            <div class="rank">{{ index + 4 }}</div>
            <div class="img"><img :src="item.picUrl" alt="" /></div>
            <div class="name">{{ item.name }}</div>
            <div class="score">热度:{{ item.score }}</div>
          </li>
        </ul>
      </div>
    </el-main>

  </el-container>
</template>

<script>
import { getSinger } from "util/findMusic";

export default {
  name: "",
  data() {
    return {
      currentIndex: 0,
      type: "",
      adress: ["华语", "欧美", "韩国", "日本"],
      list: [],
    };
  },
  created() {
    this.getSinger();
  },
  methods: {
    async getSinger() {
      let {
        data: {
          list: { artists },
        },
      } = await getSinger(this.type);
      //   console.log(artists);
      this.list = artists;
    },
    itemClick(index, type) {
      this.currentIndex = index;
      this.type = type;
      this.getSinger(type);
    },
    toDetail(id) {
      this.$router.push("/singerDetail/" + id);
    },
  },
};
</script>

<style scoped>
.elcontainer {
  padding: 0;
}
.el-header {
  width: 100%;
  background: #fff;
  position: fixed;
  margin-top: 0px;
  cursor: pointer;
  margin-bottom: 10px;
  z-index: 99;
  border-bottom: 1px solid #eee;
}
.el-header .title {
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 10px;
}
.el-header .adress {
  display: inline-block;
  font-size: 15px;
  font-weight: 500;
  margin-right: 30px;
  padding-bottom: 50px;
}
.el-header .adress.active {
  color: red;
}

.el-main {
  margin-top: 80px;
  padding: 20px 0px;
  /* border-top: 1px solid #eee; */
}
.el-col {
  /* background: #000; */
  background: #fafafa;
  margin-right: 52px;
}
.top {
  padding-left: 50px;
  margin-bottom: 20px;
}
.top .left {
  padding-left: 20px;
  float: left;
  line-height: 50px;
}

.top .left span {
  font-size: 12px;
  color: rgb(128, 120, 120);
}
.top .rank {
  margin-top: 20px;
  margin-left: 30px;
  float: left;
  font-size: 50px;
  font-weight: 600;
  color: #b7f0f8;
}
.top .img {
  width: 100px;
  height: 100px;
  overflow: hidden;
  float: right;
}
.top .img img {
  width: 100%;
  height: 100%;
}
.all ul li {
  padding-left: 20px;
  display: flex;
  height: 80px;
  background: #f9f9f9;
  align-items: center;
}
.all ul li:nth-child(2n) {
  background: #fff;
}
.all ul li:hover {
  background: #f0f1f2;
}
.all ul li .rank {
  width: 30px;
  text-align: center;
  font-size: 20px;
  color: #ddd;
}
.all ul li .img {
  width: 60px;
  height: 60px;
  margin-left: 30px;
  margin-right: 10px;
}
.all ul li .img img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}
.all ul li .name {
  flex: 1;
}
.all ul li .score {
  width: 150px;
  font-size: 12px;
  color: rgb(128, 120, 120);
}
</style>